/**
 * description
 * <p>fill description</p>
 * @author zido
 * @since 2017/5/30 0030
 */
import {combineReducers} from 'redux'
import locationReducer from './location'
import NProgress from 'nprogress'
export const makeRootReducer = (asyncReducers)=> {
  return combineReducers({
    location:locationReducer,
    ...asyncReducers
  })
}

export const injectReducer = (store,{ key , reducer }) => {
  NProgress.done()
  if(Object.hasOwnProperty.call(store.asyncReducers,key)) return
  store.asyncReducers[key] = reducer
  store.replaceReducer(makeRootReducer(store.asyncReducers))
}

export default makeRootReducer